#ifndef AUDIO_CHANNEL
#define AUDIO_CHANNEL

#include "base/Bases.h"
#include "commons/SafeQueue.h"

#include <faac.h>
#include <rtmp.h>

#include <sys/types.h>

class AudioChannel {

    private:

    uint32_t startTime;

    int channels;

    //输入样本数
    u_long inputSampleCount;
    //输出字节数
    u_long outputBufferSize;
    //输出缓冲区
    u_char *outputBuffer = nullptr;

    //编码器
    faacEncHandle codec = nullptr;

    protected:

    public:

    AudioChannel();

    ~AudioChannel();

    //设置音频编码信息
    void setAudioEncodeInfo(int sampleRate, int channels);

    //获取一次输入的样本数
    int getInputSamples();

    //设置推流开始时的时间戳
    void setStartTime(uint32_t startTime) {
        this->startTime = startTime;
    }

    //生成存储AudioSpecificConfig的Packet
    RTMPPacket *createConfigPacket();

    //生成存储音频裸数据的Packet
    RTMPPacket *createRawDataPacket(int8_t *data);
};

#endif

